﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestHarnessWebRole._Default" EnableViewState="false" %>
<%@ Register TagPrefix="x" TagName="TestBlock" Src="~/TestBlock.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Storage Client Extensions Test Harness</title>
    <script type="text/javascript" src="syntaxhighlighter/src/shCore.js"></script>
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushCSharp.js"></script>
    <link href="syntaxhighlighter/styles/shCore.css" rel="stylesheet" type="text/css" />
    <link href="syntaxhighlighter/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body, td
        {
            font-family: Arial;
        }
        
        h2
        {
            background-color: #cce4fe;
            padding: 3px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <h1>Storage Client Extensions Test Harness</h1>
        
        <x:TestBlock runat="server" id="RawCustomerTest" Title="Raw Customers">
            <Code>
                from x in context.Customers
                select x;
            </Code>
        </x:TestBlock>
    
        <x:TestBlock runat="server" id="RawOrderTest" Title="Raw Orders">
            <Code>
                from x in context.Orders
                select x;
            </Code>
        </x:TestBlock>
    
        <x:TestBlock runat="server" id="Test1" Title="Test 1: Select()">
            <Code>
                from x in context.Customers
                select new
                {
                    x.FirstName,
                    x.LastName
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test2" Title="Test 2: Join()">
            <Code>
                from o in context.Orders
                join c in context.Customers on o.CustomerId equals c.RowKey
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                };
            </Code>
        </x:TestBlock>

        <x:TestBlock runat="server" id="Test3" Title="Test 3: Join() (asynchronous)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, Async = true } equals new { c.RowKey, Async = true }
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                };
            </Code>
        </x:TestBlock>

       <x:TestBlock runat="server" id="Test4" Title="Test 4: Join() and Where()">
            <Code>
                from o in context.Orders
                join c in context.Customers on o.CustomerId equals c.RowKey
                where o.OrderNo == "20020"
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                }
            </Code>
        </x:TestBlock>

       <x:TestBlock runat="server" id="Test5" Title="Test 5: Join() on multiple properties">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, PartitionKey = "Customers" } equals new { c.RowKey, c.PartitionKey }
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                };
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test6" Title="Test 6: Join() on multiple properties (asynchronous)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, PartitionKey = "Customers", Async = true } equals new { c.RowKey, c.PartitionKey, Async = true }
                where o.OrderNo == "20020"
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                };
            </Code>
        </x:TestBlock>
       
       <x:TestBlock runat="server" id="Test7" Title="Test 7: Multiple Joins (companies are dependent on customers)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, PartitionKey = "Customers" } equals new { c.RowKey, c.PartitionKey }
                join co in context.Companies on new { RowKey = c.CompanyId, PartitionKey = "Companies" } equals new { co.RowKey, co.PartitionKey }
                join l in context.Locations on new { RowKey = co.LocationId, PartitionKey = "Locations" } equals new { l.RowKey, l.PartitionKey }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                };
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test8" Title="Test 8: Multiple Joins (companies are dependent on orders)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, PartitionKey = "Customers" } equals new { c.RowKey, c.PartitionKey }
                join co in context.Companies on new { RowKey = o.CompanyId, PartitionKey = "Companies" } equals new { co.RowKey, co.PartitionKey }
                join l in context.Locations on new { RowKey = co.LocationId, PartitionKey = "Locations" } equals new { l.RowKey, l.PartitionKey }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                };
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test9" Title="Test 9: Multiple Joins (companies & locations are dependent on orders)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, PartitionKey = "Customers" } equals new { c.RowKey, c.PartitionKey }
                join co in context.Companies on new { RowKey = o.CompanyId, PartitionKey = "Companies" } equals new { co.RowKey, co.PartitionKey }
                join l in context.Locations on new { RowKey = o.LocationId, PartitionKey = "Locations" } equals new { l.RowKey, l.PartitionKey }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                };
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test10" Title="Test 10: Multiple Joins (asynchronous)">
            <Code>
                from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, Async = true } equals new { c.RowKey, Async = true }
                join co in context.Companies on new { RowKey = o.CompanyId, Async = true } equals new { co.RowKey, Async = true }
                join l in context.Locations on new { RowKey = o.LocationId, Async = true } equals new { l.RowKey, Async = true }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                };
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test11" Title="Test 11: First()">
            <Code>
                (from c in context.Customers
                 where c.FirstName == "Peter"
                 select new
                 {
                     c.FirstName,
                     c.LastName
                 }).First()
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test12" Title="Test 12: FirstOrDefault()">
            <Code>
                (from c in context.Customers
                 where c.FirstName == "DoesNotExist"
                 select new
                 {
                     c.FirstName,
                     c.LastName
                 }).FirstOrDefault()
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test13" Title="Test 13: Take()">
            <Code>
                (from c in context.Customers
                 select new
                 {
                     c.FirstName,
                     c.LastName
                 }).Take(3)
            </Code>
        </x:TestBlock>
        
       <x:TestBlock runat="server" id="Test14" Title="Test 14: Join() and FirstOrDefault()">
            <Code>
                (from o in context.Orders
                 join c in context.Customers on o.CustomerId equals c.RowKey
                 select new
                 {
                     o.OrderNo,
                     c.FirstName,
                     c.LastName,
                     o.Total
                 }).FirstOrDefault()
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test15" Title="Test 15: Get Continuation Token">
            <Code>
                (from c in context.Customers
                 select new
                 {
                     c.FirstName,
                     c.LastName
                 }).Take(3)
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test16" Title="Test 16: Use Continuation Token">
            <Code>
                (from c in context.Customers
                 select new
                 {
                     c.FirstName,
                     c.LastName
                 }).Take(3)
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test17" Title="Test 17: Get Continuation Token with Join">
            <Code>
                (from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, Async = true } equals new { c.RowKey, Async = true }
                join co in context.Companies on new { RowKey = o.CompanyId, Async = true } equals new { co.RowKey, Async = true }
                join l in context.Locations on new { RowKey = o.LocationId, Async = true } equals new { l.RowKey, Async = true }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                }).Take(3)
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test18" Title="Test 18: Use Continuation Token with Join">
            <Code>
                (from o in context.Orders
                join c in context.Customers on new { RowKey = o.CustomerId, Async = true } equals new { c.RowKey, Async = true }
                join co in context.Companies on new { RowKey = o.CompanyId, Async = true } equals new { co.RowKey, Async = true }
                join l in context.Locations on new { RowKey = o.LocationId, Async = true } equals new { l.RowKey, Async = true }
                select new
                {
                    o.OrderNo,
                    co.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                    Location = l.Name
                }).Take(3)
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test19" Title="Test 19: Outer Join">
            <Code>
                from o in context.Orders
                join c in context.Customers on o.CustomerId equals c.RowKey into g
                from c in g.DefaultIfEmpty()
                select new
                {
                    o.OrderNo,
                    c.FirstName,
                    c.LastName,
                    o.Total
                }
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test20" Title="Test 20: Multiple Outer Joins">
            <Code>
                from o in context.Order
                join c in context.Customer on new { RowKey = o.CustomerId, PartitionKey = "Customers" } equals new { c.RowKey, c.PartitionKey }
                join co in context.Company on new { RowKey = c.CompanyId, PartitionKey = "Companies" } equals new { co.RowKey, co.PartitionKey } into oco
                from co in oco.DefaultIfEmpty()
                join l in context.Location on new { RowKey = co == null ? null : co.LocationId, PartitionKey = "Locations" } equals new { l.RowKey, l.PartitionKey } into col
                from l in col.DefaultIfEmpty()
                select new
                {
                    o.OrderNo,
                    Name = co == null ? null : co.Name,
                    Location = l == null ? null : l.Name,
                    c.FirstName,
                    c.LastName,
                    o.Total,
                }
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test21" Title="Test 21: OrderBy (on result set only)">
            <Code>
                from x in context.Customers
                orderby x.FirstName
                select new
                {
                    x.FirstName,
                    x.LastName
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test22" Title="Test 22: OrderBy Descending (on result set only)">
            <Code>
                from x in context.Customers
                orderby x.FirstName descending
                select new
                {
                    x.FirstName,
                    x.LastName
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test23" Title="Test 23: ThenBy (on result set only)">
            <Code>
                from x in context.Customers
                orderby x.FirstName, x.LastName
                select new
                {
                    x.FirstName,
                    x.LastName
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test24" Title="Test 24: ThenBy Descending (on result set only)">
            <Code>
                from x in context.Customers
                orderby x.FirstName descending, x.LastName descending
                select new
                {
                    x.FirstName,
                    x.LastName
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test25" Title="Test 25: Query Parameter Escaping (constant, method call & CompareTo)">
            <Code>
                string searchValue = "Widget & Co.";
            
                public string GetFilterCriteria()
                {
                    return "Widget & Co.";
                }
            
                from x in context.Companies
                where x.Name == searchValue && x.Name == "Widget & Co." && x.Name == GetFilterCriteria() && x.Name.CompareTo("Widget & Co.") >= 0 && x.Name.CompareTo(searchValue) >= 0
                select new
                {
                    x.Name
                };
            </Code>
        </x:TestBlock>
        
        <x:TestBlock runat="server" id="Test26" Title="Test 26: Single Resource">
            <Code>            
                from x in context.Companies
                where x.PartitionKey == "Companies" && x.RowKey == "xxx"
                select new
                {
                    x.Name
                };
            </Code>
        </x:TestBlock>
        
        <script type="text/javascript">
            SyntaxHighlighter.all();
        </script> 
    </form>
</body>
</html>
